package com.ivan.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ivan.domain.Account;

@Repository
public class AccountDAOImpl implements AccountDAO{
	
	@Autowired  
    private SessionFactory sessionFactory;  
      
    private Session openSession() {  
        return sessionFactory.getCurrentSession();  
    }  
	
	public List<Account> getAccounts(){
		List<Account> userList = new ArrayList<Account>();  
        Query query = openSession().createQuery("from Account");  
        return userList = query.list();  	
	}

}
	